/*
 * [文 件 名]:B5MMainifestHelper.java
 * [创 建 人]:allenwang
 * [创建时间]:Oct 22, 2013
 * [编　　码]:UTF-8
 * [版　　权]:Copyright © 2012 B5Msoft Co,Ltd. 
*/

package com.core.util;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;

/**
 *	[简要描述]:
 *	[详细描述]:
 *	@author	[allenwang]
 *	@email	[allen.wang@b5m.com]
 *	@version	[版本号,Oct 22, 2013]
 *	@see		[B5MMainifestHelper]
 *	@package	[com.b5m.afw.internal]
 *	@since	[afw]
 */
public class B5MMainifestHelper
{
    public static String getChannelCode(Context context)
    {
        String code = readMetaData(context, "UMENG_CHANNEL");
        if (code != null)
        {
            B5MLog.i("MetaData UMENG_CHANNEL Channel ID:  " + code);
            return code;
        }
        return "null";
    }

    private static String readMetaData(Context context , String key)
    {
        try
        {
            ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
            Object value = ai.metaData.get(key);
            if (value != null)
            {
                return value.toString();
            }
        }
        catch (Exception e)
        {
            //
        }
        return null;
    }
}
